package com.boot.study;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.enums.WriteDirectionEnum;
import com.alibaba.excel.write.metadata.WriteSheet;

import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.boot.study.domain.*;
import com.boot.study.unit.TestFileUtil;


import org.apache.poi.ss.usermodel.Workbook;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;


/**
 * @Author: lkz
 * @Title: TestExcelDemo
 * @Description: TODO
 * @Date: 2023/7/21 16:42
 */

public class TestExcelDemo {



    /**
     * 最简单的填充
     *
     * @since 2.1.1
     */
    @Test
    public void simpleFill() {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        String templateFileName =
                TestFileUtil.getPath() + "excel" + File.separator + "simple.xlsx";

        // 方案1 根据对象填充
//        String fileName = TestFileUtil.getPath() + "simpleFill" + System.currentTimeMillis() + ".xlsx";
//        System.out.println(fileName);
        // 这里 会填充到第一个sheet， 然后文件流会自动关闭
//        FillData fillData = new FillData();
//        fillData.setName("张三");
//        fillData.setNumber(5.2);
//        EasyExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(fillData);

        // 方案2 根据Map填充
      String  fileName = "D:\\" + System.currentTimeMillis() + ".xlsx";
        System.out.println(fileName);
        // 这里 会填充到第一个sheet， 然后文件流会自动关闭
        Map<String, Object> map = new HashMap<>();
        map.put("name", "张三");
        map.put("number", 5.2);
        map.put("num", 5.8);
        EasyExcel.write(fileName).withTemplate(templateFileName).sheet().doFill(map);
    }


    @Test
    public void complexFillWithTable() throws IOException {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量
        // 这里模板 删除了list以后的数据，也就是统计的这一行
//        String templateFileName =
//            TestFileUtil.getPath() + "demo" + File.separator + "fill" + File.separator + "complexFillWithTable.xlsx";
        ClassPathResource classPathResource = new ClassPathResource("excel/complexFillWithTable.xlsx");
        InputStream templateFileName = classPathResource.getInputStream();
        String fileName = "D://" + "complexFillWithTable" + System.currentTimeMillis() + "demo.xlsx";
        System.out.println(fileName);

        // 方案1
        try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) {
            WriteSheet writeSheet = EasyExcel.writerSheet().build();

            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
            workbook.setForceFormulaRecalculation(true);// 直接写入数据
            excelWriter.fill(data(), writeSheet);
            // excelWriter.fill(data(), writeSheet);

            // 写入list之前的数据
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("date", "2019年10月9日13:28:28");
            map.put("total", "2019年10月9日13:28:28");
            excelWriter.fill(map, writeSheet);

            // list 后面还有个统计 想办法手动写入
            // 这里偷懒直接用list 也可以用对象
//            List<List<String>> totalListList = ListUtils.newArrayList();
//            List<String> totalList = ListUtils.newArrayList();
//            totalListList.add(totalList);
////            totalList.add(null);
////            totalList.add(null);
////            totalList.add(null);
//            // 第四列
//            totalList.add("统计:1000");
//            // 这里是write 别和fill 搞错了
//            excelWriter.write(totalListList, writeSheet);
            // 总体上写法比较复杂 但是也没有想到好的版本 异步的去写入excel 不支持行的删除和移动，也不支持备注这种的写入，所以也排除了可以
            // 新建一个 然后一点点复制过来的方案，最后导致list需要新增行的时候，后面的列的数据没法后移，后续会继续想想解决方案
        }
    }

    /**
     * 测试模版填充组合指定表头
     * @throws IOException
     */
    @Test
    public void complexFillWithTableManySheet() throws IOException {

        ClassPathResource classPathResource = new ClassPathResource("excel/complexFillWithTable.xlsx");
        InputStream templateFileName = classPathResource.getInputStream();
        String fileName = "D://" + "complexFillWithTable" + System.currentTimeMillis() + "demo.xlsx";
        System.out.println(fileName);

        // 方案1
        try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) {
            WriteSheet writeSheet = EasyExcel.writerSheet(0,"模版填充数据").build();
            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
            workbook.setForceFormulaRecalculation(true);// 直接写入数据
            excelWriter.fill(data(), writeSheet);
            // excelWriter.fill(data(), writeSheet);

            // 写入list之前的数据
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("date", "2019年10月9日13:28:28");
            map.put("total", "2019年10月9日13:28:28");
            excelWriter.fill(map, writeSheet);
           // WriteSheet writeSheetDto = EasyExcel.writerSheet(1,"集合数据").head(LandmarkExcel.class).build();
            WriteTable writeTable2 = EasyExcel.writerTable(1).head(LandmarkExcel.class).build();

            // 第一次写入会创建头
            List<LandmarkExcel> dataList=new ArrayList<>();
            for(int i=0;i<10;i++){
                LandmarkExcel excel = new LandmarkExcel();
                excel.setProLandmark("名称："+i);
                excel.setActBegTime("时间-"+i);
                dataList.add(excel);
            }
           // excelWriter.write(dataList,writeSheet);
            excelWriter.write(dataList,writeSheet,writeTable2);
        }
    }

    @Test
    public void complexFillWithTableCostTempalte() throws IOException {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量
        // 这里模板 删除了list以后的数据，也就是统计的这一行
//        String templateFileName =
//            TestFileUtil.getPath() + "demo" + File.separator + "fill" + File.separator + "complexFillWithTable.xlsx";
        ClassPathResource classPathResource = new ClassPathResource("excel/projectCostTemplate.xlsx");
        InputStream templateFileName = classPathResource.getInputStream();
        String fileName = "D://" + "proCostTableTem" + System.currentTimeMillis() + "demo.xlsx";

        // 方案1
        try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) {
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
            workbook.setForceFormulaRecalculation(true);// 直接写入数据
         //   FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).direction(WriteDirectionEnum.VERTICAL).build();

            FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();


            // 里程碑数据

            //逐年分解
            List<YearResolve> yearResolves = this.initYear();
         //   excelWriter.fill(new FillWrapper("landmark", landmarks),fillConfig, writeSheet);
            excelWriter.fill(new FillWrapper("year", yearResolves),fillConfig, writeSheet);
            Map<String,List<EsOptionBaseDTO>> mapBase=new ConcurrentHashMap<>();

            // 因为有多个模版码表填充 当存在多个码表需要填充 需要根据数据行数排序 行数少的先填充 否则会出现数据丢失问题
            List<Map.Entry<String, List<EsOptionBaseDTO>>> collect = new ArrayList<>(mapBase.entrySet());

            collect.sort((a, b) -> {
                if (a.getValue().size() == b.getValue().size()) {
                    return 0;
                }
                return a.getValue().size() > b.getValue().size() ? 1 : -1;
            });
            for (Map.Entry<String, List<EsOptionBaseDTO>> stringListEntry : collect) {
                // 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1，然后多个list必须用 FillWrapper包裹
                FillWrapper data = new FillWrapper(stringListEntry.getKey(), stringListEntry.getValue());
                excelWriter.fill(data, writeSheet);

            }


            // 写入list之前的数据
            Map<String, Object> map = new ConcurrentHashMap<>();
            map.put("projectName", "项目名称");
            map.put("versionTime", "2019年10月9日13:28:28");
            map.put("schemeCode", "方案版本号");
            map.put("createReportTime", DateUtil.format(new Date(),"yyyy-MM-dd"));
            map.put("actCostSum", 10);
            map.put("presentMedicCostSum", 20);
            map.put("manCostSum", 20000);
            map.put("preManCostSum", 1000);
            map.put("proCostSum", 562);
            map.put("coreNum", 4343);
            map.put("subNum", 434);
            map.put("proBegTime", "2023-07-21");
            map.put("stuCoreSum", "stuCoreSum");
            map.put("proEndTime", "2023-07-21");
            map.put("mediciSumCost", "mediciSumCost");
            map.put("supCostSum", "supCostSum");
            map.put("dataStaticCostSum", "dataStaticCostSum");
            map.put("smoCostSum", "smoCostSum");
            map.put("croCostSum", "croCostSum");
            map.put("otherCostSum", "otherCostSum");
            map.put("articleCostSum", "articleCostSum");


            excelWriter.fill(map, writeSheet);

        }
    }


    /**
     * 测试数据库动态
     * @throws IOException
     */
    @Test
    public void complexFillWithTableCost() throws IOException {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量
        // 这里模板 删除了list以后的数据，也就是统计的这一行
//        String templateFileName =
//            TestFileUtil.getPath() + "demo" + File.separator + "fill" + File.separator + "complexFillWithTable.xlsx";
        ClassPathResource classPathResource = new ClassPathResource("excel/projectCost.xlsx");
        InputStream templateFileName = classPathResource.getInputStream();
        String fileName = "D://" + "proCostTable" + System.currentTimeMillis() + "demo.xlsx";


        // 方案1
        try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) {
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
//            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
//            workbook.setForceFormulaRecalculation(true);// 直接写入数据
            FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();

            //FillConfig fillConfig2 = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
            // 费用
            List<EsOptionBaseDTO> costTypes = this.initData();

            // 里程碑数据
            List<EsOptionBaseDTO> landmark = this.initLandmark();
//            List<EsOptionBaseDTO> dataList=new ArrayList<>();
//            dataList.addAll(esOptionBaseDTOS);
//            dataList.addAll(optionBaseDTOS);
            // 判断两个list大小
            List<EsOptionBaseDTO> costLandList=new ArrayList<>();
            if(costTypes.size()>landmark.size()){
                for(int i=0;i<costTypes.size();i++){
                    EsOptionBaseDTO baseDTO = new EsOptionBaseDTO();
                    EsOptionBaseDTO cost = costTypes.get(i);
                    baseDTO.setCost(cost.getCost());
                    baseDTO.setCostName(cost.getCostName());
                    if(CollUtil.isNotEmpty(landmark)&&landmark.size()>i){
                        EsOptionBaseDTO mark = landmark.get(i);
                        baseDTO.setProLandmark(mark.getProLandmark());
                        baseDTO.setActBegTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
                    }
                    costLandList.add(baseDTO);
                }
            }else{
                for(int i=0;i<landmark.size();i++){
                    EsOptionBaseDTO baseDTO = new EsOptionBaseDTO();
                    EsOptionBaseDTO dto = landmark.get(i);
                    baseDTO.setProLandmark(dto.getProLandmark());
                    baseDTO.setActBegTime(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
                    if(CollUtil.isNotEmpty(costTypes)&&costTypes.size()>i){
                        EsOptionBaseDTO cost = costTypes.get(i);
                        baseDTO.setCost(cost.getCost());
                        baseDTO.setCostName(cost.getCostName());
                    }
                    costLandList.add(baseDTO);
                }
            }
            //逐年分解
            List<YearResolve> yearResolves = this.initYear();
//            excelWriter.fill(new FillWrapper("landmark", landmarks),fillConfig, writeSheet);
            excelWriter.fill(new FillWrapper("data", costLandList),fillConfig, writeSheet);
            excelWriter.fill(new FillWrapper("year", yearResolves),fillConfig, writeSheet);
//            Map<String, List<EsOptionBaseDTO>> listMap = dataList.stream().collect(Collectors.groupingBy(EsOptionBaseDTO::getDataType));
//            List<Map.Entry<String, List<EsOptionBaseDTO>>> collect = new ArrayList<>(listMap.entrySet());
//
//            // 因为有多个模版码表填充 当存在多个码表需要填充 需要根据数据行数排序 行数少的先填充 否则会出现数据丢失问题
//            collect.sort((a, b) -> {
//                if (a.getValue().size() == b.getValue().size()) {
//                    return 0;
//                }
//                return a.getValue().size() > b.getValue().size() ? 1 : -1;
//            });
//            for (Map.Entry<String, List<EsOptionBaseDTO>> stringListEntry : collect) {
//                // 如果有多个list 模板上必须有{前缀.} 这里的前缀就是 data1，然后多个list必须用 FillWrapper包裹
//                FillWrapper data = new FillWrapper(stringListEntry.getKey(), stringListEntry.getValue());
//                excelWriter.fill(data, fillConfig,writeSheet);
//
//            }




            // 写入list之前的数据
            Map<String, Object> map = new ConcurrentHashMap<>();
            map.put("projectName", "项目名称");
            map.put("versionTime", "2019年10月9日13:28:28");
            map.put("schemeCode", "方案版本号");
            map.put("createReportTime", DateUtil.format(new Date(),"yyyy-MM-dd"));
            map.put("actCostSum", 10);
            map.put("presentMedicCostSum", 20);
            map.put("manCostSum", 20000);
            map.put("preManCostSum", 1000);
            map.put("proCostSum", 562);
            map.put("coreNum", 4343);
            map.put("subNum", 434);
            map.put("proBegTime", "2023-07-21");
            map.put("proEndTime", "2023-07-21");
            //研究中心总费用
            Map<String, Object> dataStuCoreSumCost = this.initDataStuCoreSumCost(map);
            //药品总费用
            this.initDataMedicineCostSum(map);
            //供应商总费用
            this.initDataSupSumCost(map);
            // 其他总费用
            this.initDataOtherSumCost(map);
            //文章发表总费用
            this.initDataArticle(map);
            //Ⅵ-赠药成本汇总
            //Ⅶ-人力成本总费用

            excelWriter.fill(map, writeSheet);

        }
    }


    @Test
    public void complexFillWithTableCostConfig() throws IOException {
        // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
        // {} 代表普通变量 {.} 代表是list的变量
        // 这里模板 删除了list以后的数据，也就是统计的这一行
        ClassPathResource classPathResource = new ClassPathResource("excel/projectCostConfig.xlsx");
        InputStream templateFileName = classPathResource.getInputStream();
        String fileName = "D://" + "proCostConfig" + System.currentTimeMillis() + "demo.xlsx";


        // 方案1
        try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build()) {
            WriteSheet writeSheet = EasyExcel.writerSheet().build();
//            Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
//            workbook.setForceFormulaRecalculation(true);// 直接写入数据
            FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();

            //逐年分解


            // 写入list之前的数据
            Map<String, Object> map = new ConcurrentHashMap<>();
            //研究中心总费用
           this.initDataStuCoreSumCost(map);
            //药品总费用
            this.initDataMedicineCostSum(map);
            //供应商总费用
            this.initDataSupSumCost(map);
            // 其他总费用
            this.initDataOtherSumCost(map);
            //文章发表总费用
            this.initDataArticle(map);
            //Ⅵ-赠药成本汇总
            //Ⅶ-人力成本总费用

            map.put("projectName", "项目名称");
            map.put("versionTime", "2019年10月9日13:28:28");
            map.put("schemeCode", "方案版本号");
            map.put("createReportTime", DateUtil.format(new Date(),"yyyy-MM-dd"));
            map.put("actCostSum", 10);
            map.put("presentMedicCostSum", 20);
            map.put("manCostSum", 20000);
            map.put("preManCostSum", 1000);
            map.put("proCostSum", 562);
            map.put("coreNum", 4343);
            map.put("subNum", 434);
            map.put("proBegTime", "2023-07-21"); // 项目开始时间
            map.put("proEndTime", "2023-07-21");// 项目结束时间
            map.put("typeStuCoreSumCost", map.get("typeStuCoreSumCost")); //研究中心总费用
            map.put("typeMedicineSumCost", map.get("typeMedicineSumCost"));//药品总费用
            map.put("typeSupSumCost", map.get("typeSupSumCost"));//供应商总费用
            map.put("manySystemCostSumAdd", (String)map.get("manySysCostSum")+map.get("satisAnCostSum"));// 供应商+数据管理
            map.put("smoCostSum",map.get("smoCostSum"));// 供应商smo费用
            map.put("croCostSum",map.get("croCostSum"));// 供应商 CRo
            map.put("typeOtherSumCost","typeOtherSumCost");//其他总费用
            map.put("typeArticleSumCost","typeArticleSumCost");// 文章发表总费用
            // 里程碑时间
            map.put("firstGroupTime",DateUtil.format(new Date(),"yyyy-MM"));
            map.put("lastOneGroupTime",DateUtil.format(new Date(),"yyyy-MM"));
            map.put("subEndVisitTime",DateUtil.format(new Date(),"yyyy-MM"));
            map.put("databaseLockTime",DateUtil.format(new Date(),"yyyy-MM"));
            map.put("crsStudyReportTime",DateUtil.format(new Date(),"yyyy-MM"));
            excelWriter.fill(map, writeSheet);

            List<YearResolve> yearResolves = this.initYear();

            excelWriter.fill(new FillWrapper("year", yearResolves),fillConfig, writeSheet);

        }
    }


    public static void main(String[] args) {
        List<EsOptionBaseDTO> mapList=new ArrayList<>();
        EsOptionBaseDTO dto=new EsOptionBaseDTO();
        dto.setDataType("cost");
        dto.setCost("1000W");
        dto.setCostName("费用明细");
        mapList.add(dto);

        EsOptionBaseDTO baseDTO3 = new EsOptionBaseDTO();
        baseDTO3.setDataType("data");
        baseDTO3.setProLandmark("data里程碑名称3");
        baseDTO3.setActBegTime("2022-03-05");
        mapList.add(baseDTO3);
        EsOptionBaseDTO baseDTO4 = new EsOptionBaseDTO();
        baseDTO4.setDataType("data");
        baseDTO4.setProLandmark("data里程碑名称4");
        baseDTO4.setActBegTime("2022-03-05");
        mapList.add(baseDTO4);
        EsOptionBaseDTO baseDTO5 = new EsOptionBaseDTO();
        baseDTO5.setDataType("data");
        baseDTO5.setProLandmark("baseDTO5里程碑名称5");
        baseDTO5.setActBegTime("2022-03-05");
        mapList.add(baseDTO5);

        EsOptionBaseDTO baseDTO = new EsOptionBaseDTO();
        baseDTO.setDataType("landmark");
        baseDTO.setProLandmark("里程碑名称");
        baseDTO.setActBegTime("2022-03-05");
        mapList.add(baseDTO);
        EsOptionBaseDTO baseDTO2 = new EsOptionBaseDTO();
        baseDTO2.setDataType("landmark");
        baseDTO2.setProLandmark("里程碑名称");
        baseDTO2.setActBegTime("2022-03-05");
        mapList.add(baseDTO2);

        EsOptionBaseDTO baseDTO1 = mapList.get(10);

        Map<String, List<EsOptionBaseDTO>> listMap = mapList.stream().collect(Collectors.groupingBy(EsOptionBaseDTO::getDataType));
          List<Map.Entry<String, List<EsOptionBaseDTO>>> collect = new ArrayList<>(listMap.entrySet());
        collect.sort((a, b) -> {
            if (a.getValue().size() == b.getValue().size()) {
                return 0;
            }
            return a.getValue().size() > b.getValue().size() ? 1 : -1;
        });
        System.out.println(collect);

    }
    /**
     * 研究中心总费用
     * @param map
     * @return
     */
    public Map<String,Object> initDataStuCoreSumCost(Map<String,Object> map){
        // 研究者费
        map.put("stuUnitNum", 10); map.put("stuUnitCost", "2000");map.put("stuCostSum", "stuCostSum"); map.put("stuRemark", "stuRemark"); map.put("stuActBedSum", "stuActBedSum");
        //入组推荐费
        map.put("groupUnitNum", 20);map.put("groupUnitCost", "1000");map.put("groupCostSum", "groupCostSum");map.put("groupRemark", "groupRemark");map.put("groupActBedSum", "groupActBedSum");
        // 患者补贴
        map.put("subUnitNum", 30);map.put("subUnitCost", "1000");map.put("subUnitCostSum", "subUnitCostSum");map.put("subRemark", "subRemark");map.put("subActBedSum", "subActBedSum");
        // 研究中心管理费（管理费30%+税费6%）
        map.put("stuCoreManageUnitNum", 40);map.put("stuCoreManageUnitCost", "100");map.put("stuCoreManageCostSum", "stuCoreManageCostSum");map.put("stuCoreManageRemark", "stuCoreManageRemark");map.put("stuCoreManageActSum", "stuCoreManageActSum");
        // 其他
        map.put("stuCoreOthUnitNum", 50);map.put("stuCoreOthUnitCost", "200");map.put("stuCoreOthCostSum", "stuCoreOthCostSum");map.put("stuCoreOthRemark", "stuCoreOthRemark");map.put("stuCoreOthActSum", "stuCoreOthActSum");
        // 研究中心总费用
        map.put("typeStuCoreSumCost","typeStuCoreSumCost");

        return map;

    }

    /**
     *  药品总费用
     * @param map
     * @return
     */
    public Map<String,Object> initDataMedicineCostSum(Map<String,Object> map){
        // 药品外购
        map.put("drugOutUnitNum", 10);map.put("drugOutUnitCost", "1000");map.put("drugOutUnitCostSum", "drugOutUnitCostSum");map.put("drugOutRemark", "drugOutRemark");map.put("drugOutActBedSum", "drugOutActBedSum");
        // 药物处理(运输费)
        map.put("medicDealUnitNum", 20);map.put("medicDealUnitCost", "1000");map.put("medicDealCostSum", "medicDealCostSum");map.put("medicDealRemark", "medicDealRemark");map.put("medicDealActBedSum", "medicDealActBedSum");
        // 药品储藏
        map.put("medicineStoreUnitNum", 30);map.put("medicineStoreUnitCost", "1000");map.put("medicineStoreCostSum", "medicineStoreCostSum");map.put("medicineStoreRemark", "medicineStoreRemark");map.put("medicineStoreActBedSum", "medicineStoreActBedSum");
       // 药品销毁费
        map.put("medicDesUnitNum", 10);map.put("medicDesUnitCost", "1000");map.put("medicDesCostSum", "medicDesCostSum");map.put("medicDesRemark", "medicDesRemark");map.put("medicDesActBedSum", "medicDesActBedSum");
        //  其他
        map.put("medicOthUnitNum", 50);map.put("medicOthUnitCost", "500");map.put("medicOthCostSum", "medicOthCostSum");map.put("medicOthRemark", "medicOthRemark");map.put("medicOthActBedSum", "medicOthActBedSum");
        // Ⅱ-药品总费用（不包括赠药）
        map.put("typeMedicineSumCost", "typeMedicineSumCost");

        return map;
    }

    /**
     * 供应商总费用
     * @param map
     * @return
     */
    public Map<String,Object> initDataSupSumCost(Map<String,Object> map){
        // EDC系统+随机系统+数据管理
        map.put("manySysUnitNum", 10);map.put("manySysUnitCost", "1000");map.put("manySysCostSum", "manySysCostSum");map.put("manySysRemark", "manySysRemark");map.put("manySysActBedSum", "manySysActBedSum");
        // 统计分析外包费用
        map.put("satisAnUnitNum", 20);map.put("satisAnUnitCost", "1000");map.put("satisAnCostSum", "satisAnCostSum");map.put("satisAnRemark", "satisAnRemark");map.put("satisAnActBedSum", "satisAnActBedSum");
        // SMO费用
        map.put("smoUnitNum", "smoUnitNum");map.put("smoUnitCost", "smoUnitCost");map.put("smoCostSum", "smoCostSum");map.put("smoRemark", "smoRemark");map.put("smoActBedSum", "smoActBedSum");
        //  CRO费用
        map.put("croUnitNum", "croUnitNum");map.put("croUnitCost", "croUnitCost");map.put("croCostSum", "croCostSum");map.put("croRemark", "croRemark");map.put("croRemark", "croRemark");
       //  中心实验室费用（如适用）
        map.put("corelabUnitNum", "corelabUnitNum");map.put("corelabUnitCost", "corelabUnitCost");map.put("corelabCostSum", "corelabCostSum");map.put("corelabRemark", "corelabRemark");map.put("corelabActBedSum", "corelabActBedSum");
       // 独立影像/病理评估费用（如适用）
        map.put("aloPathUnitNum", "aloPathUnitNum");map.put("aloPathUnitCost", "aloPathUnitCost");map.put("aloPathCostSum", "aloPathCostSum");map.put("aloPathRemark", "aloPathRemark");map.put("aloPathActBedSum", "aloPathActBedSum");
       //  其他（如适用）
        map.put("supOtherUnitNum", "supOtherUnitNum");map.put("supOtherUnitCost", "supOtherUnitCost");map.put("supOtherCostSum", "supOtherCostSum");map.put("supOtherRemark", "supOtherRemark");map.put("supOtherActBedSum", "supOtherActBedSum");
        // Ⅲ-供应商总费用
        map.put("typeSupSumCost", "typeSupSumCost");

        return map;
    }

    /**
     * 其他总费用
     * @param map
     * @return
     */
    public Map<String,Object> initDataOtherSumCost(Map<String,Object> map){
        // 本地会议 (研究中心启动会)
        map.put("localCoreUnitNum", "localCoreUnitNum");map.put("localCoreUnitCost", "localCoreUnitCost");map.put("localCoreCostSum", "localCoreCostSum");map.put("localCoreRemark", "localCoreRemark");map.put("localCoreActBedSum", "localCoreActBedSum");
       // 本地会议 (全体研究者会议)
        map.put("localAllUnitNum", "localAllUnitNum");map.put("localAllUnitCost", "localAllUnitCost");map.put("localAllCostSum", "localAllCostSum");map.put("localAllRemark", "localAllRemark");map.put("localAllActBedSum", "localAllActBedSum");
        // 中心立项费
        map.put("coreProUnitNum", "coreProUnitNum");map.put("coreProUnitCost", "coreProUnitCost");map.put("coreProCostSum", "coreProCostSum");map.put("coreProRemark", "coreProRemark");map.put("coreProActBedSum", "coreProActBedSum");
        // 伦理审查费 (初审)
        map.put("ethicFirstUnitNum", "ethicFirstUnitNum");map.put("ethicFirstUnitCost", "ethicFirstUnitCost");map.put("ethicFirstCostSum", "ethicFirstCostSum");map.put("ethicFirstRemark", "ethicFirstRemark");map.put("ethicFirstActBedSum", "ethicFirstActBedSum");
       // 伦理审查修正案及年度审核
        map.put("ethicYearUnitNum", "ethicYearUnitNum");map.put("ethicYearUnitCost", "ethicYearUnitCost");map.put("ethicYearCostSum", "ethicYearCostSum");map.put("ethicYearRemark", "ethicYearRemark");map.put("ethicYearActBedSum", "ethicYearActBedSum");
        // 设备、资料印刷、快递等办公费
        map.put("szkUnitNum", "szkUnitNum");map.put("szkUnitCost", "szkUnitCost");map.put("szkCostSum", "szkCostSum");map.put("szkRemark", "szkRemark");map.put("szkActBedSum", "szkActBedSum");
        // 保险
        map.put("insureUnitNum", "insureUnitNum");map.put("insureUnitCost", "insureUnitCost");map.put("insureCostSum", "insureCostSum");map.put("insureRemark", "insureRemark");map.put("insureActBedSum", "insureActBedSum");
        map.put("aeMangeUnitNum", "aeMangeUnitNum");map.put("aeMangeUnitCost", "aeMangeUnitCost");map.put("aeMangeCostSum", "aeMangeCostSum");map.put("aeMangeRemark", "aeMangeRemark");map.put("aeMangeActBedSum", "aeMangeActBedSum");
       // 业务招待费（公关及应急等）
        map.put("busReceUnitNum", "busReceUnitNum");map.put("busReceUnitCost", "busReceUnitCost");map.put("busReceCostSum", "busReceCostSum");map.put("busReceRemark", "busReceRemark");map.put("busReceActBedSum", "busReceActBedSum");
       // 其他
        map.put("otherUnitNum", "otherUnitNum");map.put("otherUnitCost", "otherUnitCost");map.put("otherCostSum", "otherCostSum");map.put("otherRemark", "otherRemark");map.put("otherActBedSum", "otherActBedSum");
        //  Ⅳ-其他总费用（会议，立项伦理费，办公费，保险和AE管理费，招待费等）
        map.put("typeOtherSumCost","typeOtherSumCost");

        return map;

    }

    /**
     * Ⅴ-文章发表总费用
     * @param map
     * @return
     */
    public Map<String,Object> initDataArticle(Map<String,Object>  map){
        // 文章发表费用-会议poster
        map.put("artPosterUnitNum", "artPosterUnitNum");map.put("artPosterUnitCost", "artPosterUnitCost");map.put("artPosterCostSum", "artPosterCostSum");map.put("artPosterRemark", "artPosterRemark");map.put("artPosterActBedSum", "artPosterActBedSum");
        // 文章发表费用-文章发表
        map.put("artPublicUnitNum", "artPublicUnitNum");map.put("artPublicUnitCost", "artPublicUnitCost");map.put("artPublicCostSum", "artPublicCostSum");map.put("artPublicRemark", "artPublicRemark");map.put("artPublicActBedSum", "artPublicActBedSum");
        // 其他
        map.put("artOtherUnitNum", "artOtherUnitNum");map.put("artOtherUnitCost", "artOtherUnitCost");map.put("artOtherCostSum", "artOtherCostSum");map.put("artOtherRemark", "artOtherRemark");map.put("artOtherActBedSum", "artOtherActBedSum");
       // Ⅴ-文章发表总费用
        map.put("artOtherCoreActBedSum","artOtherCoreActBedSum");
        return map;
    }

    public Map<String,Object> initData(Map<String,Object>  map){


        return map;
    }

    public List<EsOptionBaseDTO> initData(){
        List<EsOptionBaseDTO> dataList=new ArrayList<>();
        dataList.add(new EsOptionBaseDTO("cost","Ⅰ-研究中心总费用（研究者费+患者补贴+中心管理费）","3000"));
        dataList.add(new EsOptionBaseDTO("cost","Ⅱ-药品总费用（不包括赠药）","3000"));
        dataList.add(new EsOptionBaseDTO("cost","Ⅲ-供应商总费用","3000"));
        dataList.add(new EsOptionBaseDTO("cost","供应商费用-数据统计","3000"));
        dataList.add(new EsOptionBaseDTO("cost","供应商费用-SMO","3000"));
        dataList.add(new EsOptionBaseDTO("cost","供应商费用-CRO","3000"));
        dataList.add(new EsOptionBaseDTO("cost","Ⅳ-其他总费用（会议，立项伦理费，办公费，保险和AE管理费，招待费等）","3000"));
        dataList.add(new EsOptionBaseDTO("cost","Ⅴ-文章发表总费用","3000"));
        return dataList;
    }



    private List<FillData> data() {
        List<FillData> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            FillData fillData = new FillData();
            fillData.setName("张三");
            fillData.setNumber(5.2);
            fillData.setDate(new Date());
            list.add(fillData);
        }
        return list;
    }


    public List<YearResolve> initYear(){
        List<YearResolve> dataList=new ArrayList<>();
        for(int i=0;i<=10;i++){
            YearResolve resolve = new YearResolve();
            resolve.setExecuteYear("202"+i);
            resolve.setRatio(i+"0%");
            resolve.setProYearCost("2020"+i);
            resolve.setAdditionCostSum("33"+i);
            resolve.setActOutCostSum("101"+i);
            dataList.add(resolve);
        }

        return dataList;
    }

    public List<EsOptionBaseDTO> initLandmark(){
        List<EsOptionBaseDTO> dataList=new ArrayList<>();
        for(int i=0;i<=7;i++){
            EsOptionBaseDTO mark = new EsOptionBaseDTO();
            mark.setDataType("landmark");
           mark.setProLandmark("里程碑"+i);
           if(i!=5){
               mark.setActBegTime("2023");
           }else{
               mark.setActBegTime(null);
           }
            dataList.add(mark);
        }

        return dataList;
    }




}
